#include<bits/stdc++.h>
using namespace std;

int t;
int n,m,l,V;
int road[100010];
int d[100010],v[100010],a[100010];
bool x,x1;

inline void init(){
    scanf("%d %d %d %d",&n,&m,&l,&V);
    for(int i=1;i<=n;i++){
        scanf("%d %d %d",&d[i],&v[i],&a[i]);
        if(a[i]!=0)x=1;
        if(a[i]<=0)x1=1;
    }

    for(int i=1;i<=m;i++){
        scanf("%d",&road[i]);
    }
    sort(road+1,road+1+m);
}

inline void solve1(){
    int shu=0;
    for(int i=1;i<=n;i++){
       if(v[i]>V){
           if(d[i]<=road[m]){
            shu++;
           }
       }
    }
    printf("%d ",shu);
    if(shu==0){
        printf("%d\n",m);
    }else{
        printf("%d\n",m-1);
    }
}

inline void solve2(){
    int shu=0;
    for(int i=1;i<=n;i++){
        if(d[i]>road[m]){
            continue;
        }
        if(v[i]>V){
            shu++;
            continue;
        }

        int jv=road[m]-d[i];
        double v0=sqrt(v[i]*v[i]+2*a[i]*jv);
        if(v0>V)shu++;

    }
    printf("%d ",shu);
    if(shu==0){
        printf("%d\n",m);
    }else{
        printf("%d\n",m-1);
    }
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    cin >> t;
    while(t--){
        init();
        if(!x)solve1();
        else if(!x1)solve2();
    }

    return 0;
}
